#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int dollor[4] = { 0 };
void Bubble_sort(int digit, int* digits)
{
	int a = 0, b = 1;
	for (int i = 0; i < digit - 1; i++) {
		a = 0;
		b = 1;
		for (int j = 0; j < digit - 1 - i; j++) {
			if (digits[a] > digits[b]) {
				digits[a] = digits[a] + digits[b];
				digits[b] = digits[a] - digits[b];
				digits[a] = digits[a] - digits[b];
			}
			a++;
			b++;
		}
	}
}
int main()
{
	float gs;
	int n, dol;
	scanf("%f", &gs);
	for (int i = 0; i < 3; i++) {
		scanf("%d%d", &n, &dol);
		if ((int)(gs / n) < (gs / n)) { n = (int)(gs / n) + 1; dollor[i] = n * dol; }
		else { n = (int)(gs / n); dollor[i] = n * dol;}
	}
	Bubble_sort(3, dollor);
	printf("%d", dollor[0]);
	return 0;
}